﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows .Forms ;

namespace 提交管理平台V1
{
    class NodesInfo
    {
        List<string> Path;
        List<IntPtr> Handle;

        public NodesInfo(TreeView tv)
        {
            Path = new List<string>();
            Handle = new List<IntPtr>();
            for (int i = 0; i < tv.Nodes.Count; i++)
            {
                Path.Add(tv.Nodes[i].FullPath);
                Handle.Add(tv.Nodes[i].Handle);
                GetChildNodesInfo(tv.Nodes[i]);
            }
        }

        private void GetChildNodesInfo(TreeNode tn)
        {
            for (int i = 0; i < tn.Nodes.Count ; i++)
            {
                Path.Add(tn.Nodes[i].FullPath);
                Handle.Add(tn.Nodes[i].Handle);
            }
        }

        public IntPtr GetNodeHandle(string strPath)
        {
            int idx = Path.IndexOf(strPath);
            if (idx >= 0)
            {
                return Handle[idx];
            }
            else
            {
                return new IntPtr();
            }
        }
    }
}
